Skip to content

fix(beta/tools): raise StopResponse after send_dtmf_events to yield turn#5397

Open
ibiscp wants to merge 1 commit intolivekit:mainfrom
ibiscp:fix/send-dtmf-stop-response
Open

fix(beta/tools): raise StopResponse after send_dtmf_events to yield turn#5397
ibiscp wants to merge 1 commit intolivekit:mainfrom
ibiscp:fix/send-dtmf-stop-response

Conversation

@ibiscp
Copy link
Copy Markdown

@ibiscp ibiscp commented Apr 9, 2026

Problem

IVR (Interactive Voice Response) navigation is one of the primary use cases for voice agents using send_dtmf_events. In this context, after pressing digits the agent has no meaningful action to take — it must stay silent and listen for the IVR's next prompt. This is not a preference, it is the required protocol: speaking or taking further action before the IVR responds will confuse the system and break the call flow.

However, because send_dtmf_events returns a success string, the LLM receives a tool result and is immediately re-invoked to generate a response. This causes the agent to speak, narrate, or call additional tools before the IVR has had a chance to react to the keypress.

The only way to work around this today is to define a separate no-op tool (e.g. listen_and_wait) that raises StopResponse, then hardcode in the system prompt that it must be called after every single send_dtmf_events invocation. This is unnecessary boilerplate that every IVR agent developer must rediscover and add independently — and it is easy to forget, causing silent, hard-to-debug failures.

Fix

StopResponse is the idiomatic LiveKit Agents mechanism to signal that a tool has completed its work and the agent should yield the turn without generating a response. Raising it at the end of send_dtmf_events encodes the correct behavior directly in the tool, so developers get the right semantics automatically without any prompt engineering or extra tools. The error path still returns a descriptive string so the LLM can be aware of failures and decide whether to retry.

Impact

  • Breaking: the tool no longer returns a success string on the happy path. Agents that inspect the return value of send_dtmf_events will need to be updated (no known first-party usage of the return value).
  • No changes to the public API surface; StopResponse is already exported from livekit.agents.

@ibiscp ibiscp changed the title fix: raise StopResponse after send_dtmf_events to yield turn fix(beta/tools): raise StopResponse after send_dtmf_events to yield turn Apr 9, 2026
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant